﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

using Baza.EF.BLL;
using Baza.EF.DAL;

namespace Pep_3014_3070_Desktop
{
    public partial class AddOwner : Form
    {
        public AddOwner()
        {
            InitializeComponent();
        }
        private void btnSpremi_Click(object sender, EventArgs e)
        {

            Owners owner = new Owners();

            // Countries country = (Countries)drzavaCmb.SelectedItem;

            owner.FirstName = imeInput.Text.Trim();
            owner.LastName = prezimeInput.Text.Trim();
            owner.Email = emailInput.Text.Trim();
            owner.CellNumber = TextBoxMobilni.Text;
            owner.BusinessNumber = TextBoxPoslovni.Text;
            owner.HomeNumber = TextBoxFiksni.Text;
            owner.FaxNumber = TextBoxFiksni.Text;
            owner.AdditionalContactInfo = TextBoxInformacije.Text;
            owner.WebsiteURL = textBoxWebSite.Text;

            owner.PasswordSalt = UIHelper.GenerateSalt();
            owner.PasswordHash = UIHelper.GenerateHash(passwordInput.Text, owner.PasswordSalt);



            DAIznajmljivaciApartmani.InsertOwners(owner);

            MessageBox.Show(Global.GetString("owner_succ"), "Iznajmljivači", MessageBoxButtons.OK, MessageBoxIcon.Information);

        }

        private void NewOwnerForm_Load(object sender, EventArgs e)
        {
            cmbGrad.DataSource = DAIznajmljivaciApartmani.SelectCities();
            cmbGrad.DisplayMember = "Name";
        }

        private void btnOdustani_Click(object sender, EventArgs e)
        {
            this.Close();
        }
    }
}
